package com.test.shiro.filter;

import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;

import com.test.entity.SysUser;
import com.test.service.SysUserService;

public class WithNavibarFormAuthenticationFilter extends FormAuthenticationFilter {

	@Autowired
	private SysUserService userService;

	@Override
	protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request,
			ServletResponse response) throws Exception {
		HttpServletRequest httpReq = (HttpServletRequest) request;

		String userName = (String) SecurityUtils.getSubject().getPrincipal();
		/* List navigationBar=userService.getNavigationBar(userName); */
		List navigationBar = null;
		httpReq.getSession().setAttribute("navibar", navigationBar);
		SysUser user = new SysUser();
		httpReq.getSession().setAttribute("user", user);
		return super.onLoginSuccess(token, subject, request, response);
	}

}
